<extend name="layout/edit" />

<block name="HEADER">

</block>

<block name="CONTENT">
    <div style="height: calc(100% - 42px);">
    	<control:grid id="levelGrid" />
	</div>
    <div class="xw-form">
		<div class="xw-btnRow" style="text-align: right;">
			<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="$.close()">
				关闭
			</button>
		</div>
	</div>
</block>

<block name="FOOTER">
   <script type="text/javascript">
    var  page=(function(ns){
    	
		ns.init = function(){
			if(parent.__draws){
				levelGrid.addRow(parent.__draws)
			}else{
				levelGrid.load([{"field":"specs_id","opera":"=","value": $.getRequest('specs_id') }]);
			}
		}
		
		//新增行
		ns.addRow = function(){
			levelGrid.addRow([{
				level:'',
				name:'',
				discounts:'',
				commission_one:'',
				commission_two:'',
			}]);
		}
		
		ns.deleteRow = function(){
			levelGrid.deleteRow();    
		}
	
		//保存
		ns.save = function(){
			if(!levelGrid.verification()){
				return false;
			}
			parent.page.drawCallback( levelGrid.getRows() );
			$.close();
		}
		
        return ns;
    }({}));
    
    $(function(){ page.init(); });
   </script>
</block>



